<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const str = 'java很不催，JAVA哈哈哈'
        const re = str.replace(/java/gi, '前端')
        // const re = str.replace(/java|JAVA/gi, '前端')
        //i的意思是寻找不区分大小写 g是全局替换 不加g只会替换第一个
        console.log(re);
    </script>
</body>

</html>